home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / asm / games / scrolling_8way / 8wayscroll.asm next >
Assembly Source File  |  1980-01-03  |  18KB  |  864 lines

  1. ;******************************************************************
  2. ;******************************************************************
  3. ;***                                ***
  4. ;***    8-Way-Tile-Scroller                    ***
  5. ;***                                ***
  6. ;***    $VER: 8-Way-Tile-Scroller V1.04 (14.06.93)        ***
  7. ;***                                ***
  8. ;***                                ***
  9. ;***    Coding: Gonzo, Green Rabbits Inc.  (no scene-group)    ***
  10. ;***                                ***
  11. ;***    Contact me via EMail: hollosi@fm11ap01.tu-graz.ac.at    ***
  12. ;***                (only until 1.7.1993)        ***
  13. ;***    or via snail mail:  Arno Hollosi            ***
  14. ;***                Oberndorf 313            ***
  15. ;***                A-6322 Kirchbichl            ***
  16. ;***                AUSTRIA                ***
  17. ;***                                ***
  18. ;***    All rights reserved.                    ***
  19. ;***    You are allowed to use this source for your personel    ***
  20. ;***    purposes. Any commercial usage without the written    ***
  21. ;***    permission of the author is prohibited.            ***
  22. ;***    Using this routine in any commercial product is        ***
  23. ;***    forbidden. PD and FreeWare authors may use it in    ***
  24. ;***    their products, if they mention me in the credits.    ***
  25. ;***                                ***
  26. ;***                                ***
  27. ;***    You use this source at your own risk. Never will I be    ***
  28. ;***    liable for any damage caused by using this source;    ***
  29. ;***    dircet or indirect.                    ***
  30. ;***                                ***
  31. ;***    Copying this source is allowed, if all files are    ***
  32. ;***    provided AND were not modified before.            ***
  33. ;***                                ***
  34. ;******************************************************************
  35. ;******************************************************************
  36.  
  37.  
  38.  
  39. ;------------------------------------------------
  40. ;------------------- Offsets --------------------
  41. ;------------------------------------------------
  42.  
  43. ;exec.library
  44.  
  45. ExecBase    equ 4
  46. OpenLibrary    equ -408
  47. CloseLibrary    equ -414
  48. AllocMem    equ -198
  49. FreeMem        equ -210
  50. Disable        equ -120
  51. Enable        equ -126
  52.  
  53. ;graphics.library
  54.  
  55. OwnBlitter    equ -456
  56. DisownBlitter    equ -462
  57. LoadView    equ -222
  58. WaitTOF        equ -270
  59.  
  60. ActiView    equ 34
  61. copinit        equ 38
  62.  
  63.  
  64.  
  65. ;------------------------------------------------
  66. ;----------------- Register ---------------------
  67. ;------------------------------------------------
  68.  
  69.  
  70. dmacon   equ  $96
  71. dmaconr  equ  $02
  72.  
  73. cia_a    equ  $bfe001    ;Mouse-Register
  74.  
  75. bltcon0  equ  $40    ;BlitterRegister
  76. bltcon1  equ  $42
  77. bltafwm  equ  $44
  78. bltcpth  equ  $48
  79. bltbpth  equ  $4c
  80. bltapth  equ  $50
  81. bltdpth  equ  $54
  82. bltsize  equ  $58
  83. bltcmod  equ  $60
  84. bltbmod  equ  $62
  85. bltamod  equ  $64
  86. bltdmod  equ  $66
  87.  
  88.  
  89.  
  90.  
  91. ;------------------------------------------------
  92. ;-------------------  Makros  -------------------
  93. ;------------------------------------------------
  94.  
  95.  
  96. LIBF:    macro            ;libbase, funcoffset
  97.     move.l    \1,a6
  98.     jsr    \2(a6)
  99.     endm
  100.  
  101. oplib:  macro            ;oplib name,base,error
  102.     lea    \1(pc),a1
  103.     LIBF    ExecBase,OpenLibrary
  104.     move.l    d0,\2
  105.     beq    \3
  106.     endm
  107.  
  108. cllib:  macro            ;cllib base
  109.     move.l    \1(pc),a1
  110.     LIBF    ExecBase,CloseLibrary
  111.     endm
  112.  
  113.  
  114. getmem: macro            ;base, size, requirements, error
  115.     move.l    #\2,d0
  116.     move.l    #\3,d1
  117.     LIBF    ExecBase,AllocMem
  118.     move.l    d0,\1
  119.     beq    \4
  120.     endm
  121.  
  122.  
  123. freeit:    macro            ;base, size
  124.     move.l    \1(pc),a1
  125.     move.l    #\2,d0
  126.     LIBF    ExecBase,FreeMem
  127.     endm
  128.  
  129.  
  130. wait_blitter:  macro
  131. waitbl\@:
  132.     btst    #6,dmaconr(a6)        ;Wait for our mighty friend
  133.                 ;BBUSY is the 6th bit of upper byte !!!
  134.     bne.s    waitbl\@
  135.     endm
  136.  
  137.  
  138.  
  139. ;------------------------------------------------
  140. ;---------------- other defines  ----------------
  141. ;------------------------------------------------
  142.  
  143.  
  144. TILES_NUM    equ 32            ;4 Rows a 20 Tiles
  145. TILES_MODULO    equ TILES_NUM*2
  146. TILES_SIZE    equ TILES_NUM*5*16*2
  147.  
  148. SCR_WDTH    equ 18
  149. SCR_HGHT    equ 12
  150.  
  151. SCR_WRDX    equ (SCR_WDTH+4)*2    ;4 extra words
  152. SCR_LINES    equ (SCR_HGHT+3)*16    ;3*16 extra lines
  153.  
  154. LEV_XSIZE    equ 100
  155. LEV_YSIZE    equ 100
  156. LEVEL_SIZE    equ LEV_XSIZE*LEV_YSIZE*2
  157.  
  158.         ;ATTENTION!!
  159.         ;LEVEL_SIZE must be <$8000 because of relative
  160.         ;addressing-modes used in some routines
  161.  
  162. PLNE_SIZE    equ SCR_WRDX*SCR_LINES*5+(LEV_XSIZE*2)
  163.  
  164. FASTMEM        equ $01        ;MEMF_PUBLIC, because we don't
  165.                 ;want GIGAMEM to swap our stuff
  166. CHIPMEM        equ $03
  167.  
  168.  
  169.  
  170.  
  171.  
  172. ;------------------------------------------------
  173. ;-------------------  Start  --------------------
  174. ;------------------------------------------------
  175.  
  176.  
  177.     SECTION scroller_code,CODE
  178.  
  179. run:
  180.     oplib    gfxname,gfxbase,error1
  181.  
  182.     getmem    LEVEL_ADR,LEVEL_SIZE,FASTMEM,error2
  183.     getmem    PLNE_ADR,PLNE_SIZE,CHIPMEM,error3
  184.     getmem    COPPER_ADR,cop_length,CHIPMEM,error4
  185.  
  186.     move.l    gfxbase(pc),a6
  187.     move.l    ActiView(a6),oldview    ;we've to remember this one
  188.  
  189.     move.l    #0,a1            ;no View
  190.     jsr    LoadView(a6)
  191.     jsr    WaitTOF(a6)
  192.     jsr    WaitTOF(a6)        ;interlace frame
  193.  
  194.     LIBF    gfxbase,OwnBlitter
  195.     LIBF    ExecBase,Disable    ;OS says good bye
  196.  
  197.     bsr    init_all
  198.  
  199.     bsr    main            ;Just do it !!
  200.  
  201.     bsr    del_all
  202.  
  203.     LIBF    ExecBase,Enable    ;wake OS
  204.     LIBF    gfxbase,DisownBlitter
  205.  
  206.  
  207.     move.l    gfxbase(pc),a6        ;restore old view
  208.     move.l    oldview(pc),a1
  209.     jsr    LoadView(a6)
  210.     move.l    copinit(a6),$dff080    ;push it into life
  211.  
  212.  
  213. error5:    freeit    COPPER_ADR,cop_length    ;free all memory
  214. error4:    freeit    PLNE_ADR,PLNE_SIZE
  215. error3:    freeit    LEVEL_ADR,LEVEL_SIZE
  216. error2:    cllib    gfxbase
  217. error1:
  218.     moveq    #0,d0            ;don't return an error
  219.     rts
  220. ;--------------------------------------
  221.  
  222.  
  223.  
  224.  
  225.  
  226. ;------------------------------------------------
  227. ;-------------- Sub Programms  ------------------
  228. ;------------------------------------------------
  229.  
  230.  
  231.  
  232. init_all:
  233.     move.l    #$dff000,a6        ;never change a6 !!
  234.     move    dmaconr(a6),savedma    ;don't forget this
  235.  
  236.     move    #$7fff,dmacon(a6)    ;all DMA off
  237.     mulu    d0,d0            ;wait a little bit
  238.     move    #$8740,dmacon(a6)    ;Bitplane,no Copper, Blitter
  239.                     ;Blitterpri, no sprites
  240.                     ;no sound, no disk  !!!
  241.  
  242.     move.l    #-1,bltafwm(a6)    ;no blitter mask
  243.  
  244.     bsr    initvar
  245.     bsr    init_level
  246.     bsr    print_lev
  247.     bsr    init_origcopper
  248.     bsr    initcopper
  249.     rts
  250. ;------------------------------------------------
  251.  
  252. del_all:
  253.     move    #$7fff,dmacon(a6)
  254.     move    savedma(pc),d0
  255.     or    #$8000,d0
  256.     move    d0,dmacon(a6)        ;restore old DMACon
  257.     rts
  258. ;------------------------------------------------
  259.  
  260. initvar:
  261.     lea    tile_tab(pc),a0
  262.     lea    scroll_tiles,a1        ;Init Tile-Addresses
  263.     moveq    #TILES_NUM-1,d0
  264. init1:    move.l    a1,(a0)+
  265.     lea    2(a1),a1
  266.     dbra    d0,init1
  267.  
  268.     move.l    PLNE_ADR(pc),a0
  269.     lea    16*5*SCR_WRDX(a0),a0    ;don't display left and upper strip
  270.     lea    planes(pc),a1
  271.     moveq    #5-1,d0
  272. init7:    move.l    a0,20(a1)
  273.     move.l    a0,(a1)+
  274.     lea    SCR_WRDX(a0),a0
  275.     dbra    d0,init7
  276.  
  277.     rts
  278. ;-----------------------------------------------
  279.  
  280. init_origcopper:
  281.     lea    origcopper,a0
  282.  
  283.     lea    plane_list(a0),a1    ;Init-PlanePointer
  284.     lea    plane_list2+4(a0),a2    ;+4 because of WAIT-command
  285.     lea    planes(pc),a3
  286.     moveq    #5-1,d0
  287. iocp1:    move    (a3),2(a1)
  288.     move    (a3)+,2(a2)
  289.     move    (a3),6(a1)
  290.     move    (a3)+,6(a2)
  291.     lea    8(a1),a1
  292.     lea    8(a2),a2
  293.     dbra    d0,iocp1
  294.  
  295.     rts
  296. ;-----------------------------------------------
  297.  
  298. initcopper:
  299.     ;Copper was already disabled
  300.  
  301.     move    #$0038,$092(a6)        ;DDFSTRT
  302.     move    #$00c8,$094(a6)        ;DDFSTOP
  303.     move    #$3e91,$08e(a6)        ;DIWSTRT  Width: 288 Pixel
  304.     move    #$00b1,$090(a6)        ;DIWSTOP
  305.  
  306.     lea    screen_colors,a0
  307.     lea    $180(a6),a1        ;initialise colors 0-31
  308.     moveq    #32-1,d0
  309. incp1:    move    (a0)+,(a1)+
  310.     dbra    d0,incp1
  311.  
  312.     move.l    COPPER_ADR(pc),a0    ;Copy Copperlists
  313.     lea    origcopper,a1
  314.     moveq    #cop_length/4-1,d0
  315. incp3:    move.l    (a1)+,(a0)+
  316.     dbra    d0,incp3
  317.  
  318.     move.l    COPPER_ADR(pc),$80(a6)    ;COP1LC
  319.     move    #$0000,$88(a6)
  320.     move    #$8080,dmacon(a6)    ;Copper on
  321.     rts
  322. ;------------------------------------------------
  323.  
  324. init_level:
  325.     move.l    LEVEL_ADR(pc),a0
  326.     moveq    #LEV_YSIZE/2-1,d0
  327. inlev1:    moveq    #LEV_XSIZE/2-1,d1
  328. inlev2:    move    $006(a6),d2        ;Vertical Screen-position
  329.     and    #$1f,d2
  330.     lsl    #2,d2
  331.     move    d2,LEV_XSIZE*2(a0)    ;2*2 block
  332.     move    d2,(a0)+
  333.     move    d2,LEV_XSIZE*2(a0)
  334.     move    d2,(a0)+
  335.     dbra    d1,inlev2
  336.     lea    LEV_XSIZE*2(a0),a0
  337.     dbra    d0,inlev1
  338.     rts
  339. ;------------------------------------------------
  340.  
  341. print_lev:
  342.     move.l    PLNE_ADR(pc),a0        ;Prints Level (first time)
  343.     lea    16*5*SCR_WRDX+2(a0),a0    ;don't blit left and upper strip
  344.     move.l    LEVEL_ADR(pc),a1
  345.  
  346.     lea    tile_tab(pc),a4
  347.  
  348.     wait_blitter
  349.     move    #TILES_NUM*2-2,bltamod(a6)
  350.     move    #SCR_WRDX-2,bltdmod(a6)
  351.     move.l    #$09f00000,bltcon0(a6)    ;D = A
  352.  
  353.     moveq    #SCR_HGHT+2-1,d6
  354. prlev2:    moveq    #SCR_WDTH+3-1,d7    ;X-Loop
  355. prlev1:    move    (a1)+,d0
  356.     move.l    (a4,d0.w),d0        ;and Address
  357.  
  358.     wait_blitter
  359.     move.l    a0,bltdpth(a6)        ;Blit Block
  360.     move.l    d0,bltapth(a6)
  361.     move    #$1401,bltsize(a6)    ;16H*5P + 1W
  362.  
  363.     lea    2(a0),a0
  364.     dbra    d7,prlev1
  365.     lea    (SCR_WRDX*(16*4+15)+2)(a0),a0
  366.     lea    (LEV_XSIZE-SCR_WDTH-3)*2(a1),a1
  367.     dbra    d6,prlev2
  368.     rts
  369. ;-----------------------------------------------
  370.  
  371. SPEED    equ 2    ;maximum: 2
  372.  
  373. get_joy:
  374.     moveq    #0,d0
  375.     moveq    #0,d1
  376.  
  377.     move    $00c(a6),d7    ;JOY1DAT
  378.  
  379.     btst    #1,d7
  380.     beq.s    gjoynr
  381.     moveq    #SPEED,d0    ;right
  382. gjoynr:    btst    #9,d7
  383.     beq.s    gjoynl
  384.     moveq    #-SPEED,d0    ;left
  385. gjoynl:    move    d7,d6
  386.     lsr    #1,d6
  387.     eor    d7,d6
  388.     btst    #0,d6
  389.     beq.s    gjoynd
  390.     moveq    #SPEED,d1    ;down
  391. gjoynd:    btst    #8,d6
  392.     beq.s    gjoynu
  393.     moveq    #-SPEED,d1    ;up
  394. gjoynu:    btst    #7,cia_a
  395.     bne.s    gjoynf
  396.     add    d0,d0        ;fire
  397.     add    d1,d1
  398. gjoynf:
  399. ;---------------
  400.  
  401.     move    current_x(pc),d2
  402.     move    current_y(pc),d3
  403.     move    d2,old_x        ;remember 'em
  404.     move    d3,old_y
  405.     add    d0,d2            ;add speed to position
  406.     add    d1,d3
  407.  
  408.     tst    d2            ;is X-position in range ??
  409.     bpl.s    xpos1
  410.     moveq    #0,d2
  411. xpos1:    cmp    #(LEV_XSIZE-SCR_WDTH)*16,d2
  412.     ble.s    xtiny
  413.     move    #(LEV_XSIZE-SCR_WDTH)*16,d2
  414. xtiny:    move    d2,current_x
  415.  
  416.     tst    d3            ;is Y-position in range ??
  417.     bpl.s    ypos1
  418.     moveq    #0,d3
  419. ypos1:    cmp    #(LEV_YSIZE-SCR_HGHT)*16,d3
  420.     ble.s    ytiny
  421.     move    #(LEV_YSIZE-SCR_HGHT)*16,d3
  422. ytiny:    move    d3,current_y
  423.  
  424.     rts
  425. ;-----------------------------------------------
  426.  
  427. scroll:
  428. ;Scrolls Screen, if necessary
  429.  
  430.     move    current_x(pc),d2
  431.     move    current_y(pc),d3
  432.  
  433.     movem    d2/d3,-(a7)        ;Let the copper do his work
  434.     bsr    copper_scroll        ; = hardware-scrolling
  435.     movem    (a7)+,d0/d1
  436.  
  437.     move    old_x(pc),d2
  438.     move    old_y(pc),d3
  439.     sub    d2,d0            ;real speed in pixels
  440.     sub    d3,d1
  441.     bsr     blitter_scroll        ;nothing happens without him
  442.     rts
  443. ;------------------------------------------------
  444.  
  445. copper_scroll:
  446.         ;d2 = current_x, d3 = current_y
  447.  
  448.     add    #16,d2        ;don't display leftest strip
  449.     add    #16,d3        ;don't display upperst strip
  450.  
  451.     move.l    COPPER_ADR(pc),a2
  452.     lea    shift_tab(pc),a3
  453.  
  454.     move    d2,d0            ;X-Direction
  455.     and    #$0f,d2            ;pixel-offset in d2
  456.     add    d2,d2            ;Calc Shift-Value
  457.     move    (a3,d2.w),d2
  458.     move    d2,scrl_val+2(a2)    ;store it
  459.     subq    #1,d0            ;X-Word-Pos
  460.     and    #$fff0,d0
  461.     asr    #3,d0
  462.     ext.l    d0            ;X-offset
  463.     move.l    PLNE_ADR(pc),d1
  464.     add.l    d1,d0            ;d0 = PLNE_ADR + X_Offset
  465.                     ;     (no Y-Offset)
  466.     move.l    d0,d5            ;remember this value
  467.  
  468.     ext.l    d3            ;Y-Direction
  469.     divu    #(SCR_HGHT+3)*16,d3
  470.     swap    d3            ;height modulo buffer_height!
  471.     move    d3,d7            ;remember this value
  472.     muls    #SCR_WRDX*5,d3        ;5 planes
  473.     add.l    d3,d0            ;d0 = PLNE_ADR+X_Offset+Y_Offset
  474.  
  475.     sub    #3*16,d7        ;Calc Y-Position of CopperWrap
  476.     bmi.s    nosecy
  477.     moveq    #-2,d6            ;$fe is end of display
  478.     sub.b    d7,d6
  479.     bra.s    secy
  480. nosecy:    move    #$fe,d6
  481. secy:    move.b    d6,plane_list2(a2)    ;and store it
  482.  
  483.     lea    planes(pc),a1
  484.     moveq    #SCR_WRDX,d1
  485.     moveq    #5-1,d3
  486. ch_poi:    move.l    d5,20(a1)        ;change Bitplane-pointers
  487.     move.l    d0,(a1)+
  488.     add.l    d1,d0
  489.     add.l    d1,d5
  490.     dbra    d3,ch_poi
  491.  
  492.     lea    plane_list+2(a2),a0    ;copy'em into copperlist
  493.     lea    plane_list2+6(a2),a2    ;+6 because of WAIT-command
  494.     lea    planes(pc),a1
  495.     moveq    #5-1,d0
  496. ch_lst:    move    20(a1),(a2)
  497.     move    22(a1),4(a2)
  498.     move    (a1)+,(a0)
  499.     move    (a1)+,4(a0)
  500.     lea    8(a2),a2
  501.     lea    8(a0),a0
  502.     dbra    d0,ch_lst
  503.     rts
  504.  
  505. shift_tab:    dc.w $00,$ff,$ee,$dd,$cc,$bb,$aa,$99
  506.         dc.w $88,$77,$66,$55,$44,$33,$22,$11
  507. ;------------------------------------------------
  508.  
  509. bltxmc:  macro        ; d0 = SpeedX, d2 = old_X
  510.  
  511.     move    d2,d5
  512.     add    d0,d2
  513.     and    #$fff0,d2        ;d2 = new column
  514.     and    #$fff0,d5        ;d5 = old column
  515.     cmp    d5,d2
  516.     beq.s    noblpx\@        ;equal -> nothing new to do
  517.  
  518.     moveq    #\1*2,d6
  519.     asr    #3,d2
  520.     add    d2,d6            ;d6 = which column will be used
  521.  
  522.     IFEQ (\1-(-1))
  523.       bmi.s    noblpx\@        ;negative column ???
  524.     ENDIF
  525.  
  526.     IFEQ (\1-(SCR_WDTH+1))
  527.       cmp    #LEV_XSIZE*2,d6        ;after last visible column ??
  528.       bge.s    noblpx\@
  529.     ENDIF
  530.  
  531.     move    d6,d5
  532.     addq    #2,d5            ;MemPos = Level_ColPos + 2
  533.  
  534.     lea    blt_valx(pc),a0        ;init this new blit
  535.     movem    d5/d6,(a0)
  536.     move    #4*2,blt_cntx        ;blit in 4 steps
  537. noblpx\@:
  538.     endm
  539. ;---------------
  540.  
  541. bltymc:  macro        ;d1=SpeedY, d2=old_X, d3=old_Y
  542.  
  543.     move    d3,d5
  544.     add    d1,d3
  545.     and    #$fff0,d3        ;d3 = new line
  546.     and    #$fff0,d5        ;d5 = old line
  547.     cmp    d5,d3
  548.     beq.s    nobly\@            ;equal -> nothing new to blit
  549.  
  550.     moveq    #\1*2,d4
  551.     asr    #3,d3
  552.     add    d3,d4            ;d4 = which line will be used
  553.  
  554.     IFEQ (\1-(-1))
  555.       bmi.s    nobly\@            ;negative column ??
  556.     ENDIF
  557.  
  558.     IFEQ (\1-(SCR_HGHT+1))
  559.       cmp    #LEV_YSIZE*2,d4        ;after last visible line ??
  560.       bge.s    nobly\@
  561.  
  562.       add    #(SCR_HGHT+2)*2,d3    ;bottom of screen
  563.     ENDIF
  564.  
  565.     ext.l    d3
  566.     divu    #(SCR_HGHT+3)*2,d3
  567.     swap    d3            ;line modulo buffer_height
  568.  
  569.     lea    blt_valy+2(pc),a0
  570.     lsr    #3,d2
  571.     and.b    #$fe,d2            ;get offset in byte
  572.     move    d2,(a0)+        ;d2 = X-Offset
  573.     movem    d3/d4,(a0)        ;d3 = where to blit in buffer
  574.                     ;d4 = line in LEVEL_DAT
  575.     move    #4*2,blt_cnty
  576.     lea    blt_fldy(pc),a0        ;store Line in field
  577.     move    d4,(a0,d3.w)
  578. nobly\@:
  579.     endm
  580. ;---------------
  581.  
  582. blitter_scroll:
  583.     ;d0/d1  SpeedX/Y in Pixel   d2/d3 old_X/Y
  584.  
  585. bltx:    move    d2,-(a7)
  586.     tst    d0
  587.     beq.s    blty            ;no speed in X-direction
  588.     bmi.s    negx
  589.     bltxmc    (SCR_WDTH+1)        ;X-speed positive
  590.     bra.s    blty
  591. negx:    bltxmc    -1            ;X-speed negative
  592.  
  593. blty:    move    (a7)+,d2
  594.     tst    d1
  595.     beq    blt_done        ;no speed in Y-direction
  596.     bmi.s    negy
  597.     bltymc    (SCR_HGHT+1)        ;Y-speed positive
  598.     bra.s    blt_done
  599. negy:    bltymc    -1            ;Y-speed negative
  600.  
  601.  
  602. blt_done:
  603.     tst    blt_cntx        ;any work to do ???
  604.     beq.s    blt_nx
  605.     subq    #2,blt_cntx
  606.     bsr    blit_x            ;Work for X-Direction
  607. blt_nx:
  608.     tst    blt_cnty        ;any work to do ??
  609.     beq.s    blt_ny
  610.     subq    #2,blt_cnty
  611.     bsr    blit_y            ;Work for Y-Direction
  612. blt_ny:
  613.     rts
  614.  
  615.  
  616. blt_tabx:    dc.w 0,4,8,12        ;Y-POS to start blitting
  617.         dc.w 4,4,4,3        ;amount to blit
  618. blt_valx:    dc.w 0,0        ;colmemory, colnumber
  619. blt_cntx:    dc.w 0
  620.  
  621. blt_fldy:    dc.w 0,0,2,4,6,8,10,12,14,16,18,20,22,24,26
  622. blt_cnty:    dc.w 0
  623.  
  624. blt_taby:    dc.w 15,10,5,0        ;X-POS to start blitting
  625.         dc.w  6,5,5,5        ;amount to blit
  626.  
  627. blt_valy:    dc.w 0,0,0,0    ;X-off (Long), linememory, linenumber
  628. ;------------------------------------------------
  629.  
  630. blit_x:
  631.     lea    blt_valx(pc),a0
  632.     moveq    #0,d2
  633.     movem    (a0),d2/d4        ;d2 = Column in Memory
  634.                     ;d4 = which column
  635.     move    blt_cntx(pc),d5        ;d5 = phase number of blit
  636.  
  637.     move.l    LEVEL_ADR(pc),a0
  638.     lea    blt_tabx(pc),a1
  639.     lea    tile_tab(pc),a2
  640.     lea    blt_fldy(pc),a3
  641.  
  642.     move    (a1,d5.w),d6        ;Y-Position of Blocks
  643.     move    d6,d0
  644.     mulu    #16*5*SCR_WRDX,d6    ;in bytes
  645.     add.l    d2,d6            ;d2 = X-offset
  646.     move.l    PLNE_ADR(pc),a4
  647.     add.l    d6,a4            ;StartBlitPos on Screen
  648.     add    d0,d0
  649.  
  650.     move    4*2(a1,d5.w),d7        ;Number of Blocks to blit
  651.  
  652.     wait_blitter
  653.     move    #TILES_NUM*2-2,bltamod(a6)
  654.     move    #SCR_WRDX-2,bltdmod(a6)
  655.     move.l    #$09f00000,bltcon0(a6)    ;D = A, noshift
  656.     bra.s    subxd7
  657. blxlop:
  658.     move    (a3,d0.w),d1        ;Y-Pos in Level
  659.     mulu    #LEV_XSIZE,d1
  660.     add    d4,d1            ;d4 = column to blit
  661.     move    (a0,d1.w),d1        ;get LEVEL_DATA
  662.     move.l    (a2,d1.w),d1        ;and address of tile
  663.  
  664.     wait_blitter
  665.     move.l    a4,bltdpth(a6)        ;Blit Block
  666.     move.l    d1,bltapth(a6)
  667.     move    #$1401,bltsize(a6)    ;16H + 1W
  668.  
  669.     lea    16*5*SCR_WRDX(a4),a4
  670.     addq    #2,d0            ;blit into next line
  671. subxd7:    dbra    d7,blxlop
  672.     rts
  673. ;------------------------------------------------
  674.  
  675. blit_y:
  676.     lea    blt_valy(pc),a0
  677.     move.l    (a0)+,d2        ;d2 = X-Offset
  678.     movem    (a0),d3/d4    ;d3 = Line in Memory   d4 = which Line
  679.     move    blt_cnty(pc),d5        ;d5 = Pixelpos
  680.  
  681.     move.l    LEVEL_ADR(pc),a0
  682.     lea    -2(a0),a0        ;to correct X-Offset
  683.     lea    blt_taby(pc),a1
  684.     lea    tile_tab(pc),a2
  685.  
  686.     move    (a1,d5.w),d0        ;X-Position of Blocks
  687.     add    d0,d0
  688.     ext.l    d0
  689.  
  690.     move    d3,d6
  691.     mulu    #16*5*SCR_WRDX/2,d6
  692.     move.l    PLNE_ADR(pc),a4
  693.     add.l    d2,a4
  694.     add.l    d6,a4            ;StartBlitPos on Screen
  695.     add.l    d0,a4
  696.  
  697.     move    4*2(a1,d5.w),d7        ;Number of Blocks to blit
  698.  
  699.     mulu    #LEV_XSIZE,d4        ;d4 = Y-Offset in LEVEL_DAT
  700.  
  701.     wait_blitter
  702.     move    #TILES_NUM*2-2,bltamod(a6)
  703.     move    #SCR_WRDX-2,bltdmod(a6)
  704.     move.l    #$09f00000,bltcon0(a6)    ;D = A
  705.     bra.s    subyd7
  706.  
  707. blylop:    move    d4,d1
  708.     move    d2,d6
  709.     add    d0,d6
  710.     bmi.s    blynxt            ;no negative X-column please
  711.     cmp    #LEV_XSIZE*2,d6
  712.     bgt.s    blynxt            ;no greater X-column please
  713.     add    d6,d1
  714.     move    (a0,d1.w),d1
  715.     move.l    (a2,d1.w),d1        ;Adr of Tile
  716.  
  717.     wait_blitter
  718.     move.l    a4,bltdpth(a6)        ;Blit Block
  719.     move.l    d1,bltapth(a6)
  720.     move    #$1401,bltsize(a6)    ;16H + 1W
  721.  
  722. blynxt:    lea    2(a4),a4
  723.     addq    #2,d0
  724. subyd7:    dbra    d7,blylop
  725.     rts
  726. ;------------------------------------------------
  727.  
  728.  
  729. main:
  730.     move.l    4(a6),d0        ;never thought I'd need TWO of 'em
  731.     and.l    #$1ff00,d0        ;BUT this is very important on
  732.     cmp.l    #$0f000,d0        ;faster machines
  733.     bne.s    main            ;otherwise we'll recognize
  734. waitraster:                ;the same line several times
  735.     move.l    4(a6),d0
  736.     and.l    #$1ff00,d0
  737.     cmp.l    #$10100,d0
  738.     bne.s    waitraster
  739.  
  740.     bsr    get_joy            ;reads Joystick, calcs current_pos
  741.  
  742.     move.l    4(a6),old        ;*** to get time in rasterlines
  743.     move    #$555,$180(a6)        ;***
  744.  
  745.     bsr    scroll
  746.  
  747.     move    #$000,$180(a6)        ;*** to get time in rasterlines
  748.     move.l    4(a6),d0        ;***
  749.     sub.l    old(pc),d0        ;***
  750.     cmp.l    big(pc),d0        ;***
  751.     blo.s    mouse            ;***
  752.     move.l    d0,big            ;***
  753.  
  754. mouse:    btst    #6,cia_a        ;Mouse ??
  755.     bne.s    main
  756.  
  757.     move.l    big(pc),d0        ;*** beautify messured time
  758.     lsr.l    #8,d0            ;***
  759.     and    #$1ff,d0        ;***
  760.     addq    #$001,d0        ;***
  761.     move.l    d0,big            ;***
  762.  
  763.     rts
  764.  
  765. old:    dc.l 0
  766. big:    dc.l 0
  767. ;------------------------------------------------
  768.  
  769.  
  770.  
  771.  
  772.  
  773. ;------------------------------------------------
  774. ;-------------------  Datas  --------------------
  775. ;------------------------------------------------
  776.  
  777.  
  778. version:    dc.b "$VER: 8-Way-Tile-Scroller V1.00 (10.05.93)",0
  779.   even
  780.  
  781. savedma:    dc.w 0        ;System-Datas
  782. gfxbase:    dc.l 0
  783. oldview:    dc.l 0
  784.  
  785. gfxname:    dc.b "graphics.library",0
  786.   even
  787. ;------------------------------------------------
  788.  
  789. LEVEL_ADR:    dc.l 0
  790. PLNE_ADR:    dc.l 0
  791. COPPER_ADR:    dc.l 0
  792.  
  793. planes:        ds.l 5            ;Planes with Y-Offset
  794.                     ;>> plane_list
  795.         ds.l 5            ;Planes without Y-Off
  796.                     ;>> plane_list2
  797.  
  798.  
  799. ;----------------- Level-Datas ------------------
  800.  
  801.  
  802. tile_tab:    ds.l TILES_NUM        ;Addresses of Tiles
  803.  
  804. current_x:    dc.w 0
  805. current_y:    dc.w 0
  806. old_x:        dc.w 0
  807. old_y:        dc.w 0
  808.  
  809. ;------------------------------------------------
  810.  
  811.     SECTION scroller_data,DATA
  812.  
  813.  
  814. origcopper:
  815.         dc.w $180,$000
  816.  
  817. off_plane:    dc.w $e0,0000,$e2,0000    ;Bitplanes
  818.         dc.w $e4,0000,$e6,0000
  819.         dc.w $e8,0000,$ea,0000
  820.         dc.w $ec,0000,$ee,0000
  821.         dc.w $f0,0000,$f2,0000
  822.         dc.w $108,6+(4*SCR_WRDX),$10a,6+(4*SCR_WRDX)    ;Modulo
  823. ;BPLMODS must be changed by hand, if you modify SCR_WRDX
  824.  
  825.         dc.w $100,$5200
  826.  
  827. off_scrl:    dc.w $102,$00
  828.  
  829. off_plane2:    dc.w $fe01,$fffe
  830.         dc.w $e0,0000,$e2,0000    ;Bitplanes
  831.         dc.w $e4,0000,$e6,0000
  832.         dc.w $e8,0000,$ea,0000
  833.         dc.w $ec,0000,$ee,0000
  834.         dc.w $f0,0000,$f2,0000
  835.         dc.w $180,$003        ;Colors
  836.  
  837.         dc.w $fe01,$fffe
  838.         dc.w $100,$0200        ;end of screen
  839.  
  840.         dc.w $ffff,$fffe        ;End
  841.         dc.w $ffff,$fffe        ;End
  842. coppend:
  843.  
  844. plane_list    equ off_plane-origcopper
  845. plane_list2    equ off_plane2-origcopper
  846. scrl_val    equ off_scrl-origcopper
  847. cop_length    equ coppend-origcopper
  848.  
  849.  
  850. screen_colors:
  851.     dc.w $000,$AAA,$E00,$A00,$D80,$FE0,$8F0,$080
  852.     dc.w $0B6,$0DD,$0AF,$07C,$00F,$70F,$C0E,$C08
  853.     dc.w $620,$E52,$A52,$FCA,$333,$444,$555,$666
  854.     dc.w $777,$888,$999,$AAA,$CCC,$DDD,$EEE,$FFF
  855.  
  856. ;------------------------------------------------
  857.  
  858.     SECTION scroller_tiles,DATA_C
  859.  
  860. scroll_tiles:
  861.     IncBin "Scroll_tiles.raw"
  862.  
  863.  
  864.